//  This file is part of Swordbible - http://www.swordwarrior.net
//  Copyright (C) 2003-2008 Manu Mital mital.manu@gmail.com

//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#pragma once
#include "afxwin.h"
#include "pstat.h"
#include "SwordBibleFonts.h"
#include "AutoRichEditCtrl.h"

// CSearch dialog


class CSearch : public CDialog
{
	DECLARE_DYNAMIC(CSearch)

public:
	CSearch(CWnd* pParent);   // standard constructor
	sword::SWModule* pModule;
	static int cms_currentProgress;
	static void percentUpdate(char percent, void* userData); 
	static UINT Searcher(LPVOID dummy);
	static ULONG StatusDisplay(void* pData, CProgressThreadDlg* pProgressDlg);
	void HighLight();
	void HighLightWord(CString word); // helper function to HighLight
	virtual ~CSearch();

	static int count;
	static int flag;
    static int searchType;
	static BOOL isSearching;
	static CString toSearch;
	static sword::ListKey searchResults; 
	static sword::VerseKey scope;
	CStringArray searchTerms;

	CWnd * parent;
	CSwordBibleFonts font;

// Dialog Data
	enum { IDD = IDD_SEARCH };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
 

	DECLARE_MESSAGE_MAP()
public:
	// //control for the list that displays search results
	CListCtrl m_resultListControl;
	// lets user specify the book of bible where the search should start
	CComboBox m_searchStartControl;
	// lets user specify the book of bible where the search should end
	CComboBox m_searchEndControl;
	// should the search be case sensitive?
	BOOL m_IscaseSensitive;
	// match whole word when searching
	BOOL m_IsMatchWholeWord;
	// the text that user wants to search in the bible
	CString m_searchText;

	

	afx_msg void OnButtonSearch();
	virtual BOOL OnInitDialog();
	void SetSearchScope();

	BOOL m_radioEntire;
	afx_msg void OnNMDblclkListSearchresults(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnClickSearchResults(NMHDR *pNMHDR, LRESULT *pResult);
	CAutoRichEditCtrl m_resultPreview;

	afx_msg void OnAddtoVerseList();

};


